#include <bits/stdc++.h>
// 2025/02/27
// tag: 
// Author: Forever
using namespace std;

using int64 = int64_t;

int t, n, b[101];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> t;
    while (t--){
        cin >> n;
        for (int i = 2; i < n; i++)
            cin >> b[i];
        b[1] = 0, b[n] = 0;
        int flag = true;
        for (int i = 2; i < n; i++)
            if (b[i] == 0 && b[i - 1] && b[i + 1]){
                flag = false;
                break;
            }
        cout << (flag? "YES" : "NO") << endl;
    }
    return 0;
}